<?php
/**
 * @author spenceryg
 * @date 2022/11/29
 * @time 9:26 下午
 * @focus love & life
 */


namespace app\auto\model;


use app\auto\business\RelationBusiness;

class Relation extends \think\Model
{
    protected $table = 'auto_relation';

    public function getMasterNameAttr($value, $data)
    {
        return Table::find($data['table_id_master'])->getAttr('comment');
    }

    public function getSliverNameAttr($value, $data)
    {
        return Table::find($data['table_id_sliver'])->getAttr('comment');
    }


    public function getMiddleNameAttr($value, $data)
    {
        return $data['table_id_middle'] ? Table::find($data['table_id_middle'])->getAttr('comment') : '';
    }

    public function getTypeNameAttr($value, $data) {
        return RelationBusiness::$types[$data['type']];
    }
}
